svm: Simplify asm stub for vmentry/vmexit.
authorKeir Fraser <keir@xensource.com>
Sat, 12 May 2007 18:22:24 +0000 (19:22 +0100)
committerKeir Fraser <keir@xensource.com>
Sat, 12 May 2007 18:22:24 +0000 (19:22 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/svm/x86_32/exits.S
xen/arch/x86/hvm/svm/x86_64/exits.S

index 1a6a089df073c5ddd69058e3e6e3ab7f19775d0b..8c7130195b6068b9adc5247f878f58799b45fb52 100644 (file)
         andl $~3,reg;            \
         movl (reg),reg;
 
-#define HVM_MONITOR_EFLAGS 0x202 /* IF on */
-#define NR_SKIPPED_REGS    7     /* Skip SS thru EAX */
-#define HVM_SAVE_ALL_NOSEGREGS                  \
-        pushl $HVM_MONITOR_EFLAGS;              \
-        popf;                                   \
-        subl $(NR_SKIPPED_REGS*4),%esp;         \
-        pushl %ebp;                             \
-        pushl %edi;                             \
-        pushl %esi;                             \
-        pushl %edx;                             \
-        pushl %ecx;                             \
-        pushl %ebx;
-
 #define VMRUN  .byte 0x0F,0x01,0xD8
 #define STGI   .byte 0x0F,0x01,0xDC
 #define CLGI   .byte 0x0F,0x01,0xDD
 
 ENTRY(svm_asm_do_resume)
         GET_CURRENT(%ebx)
-        cli                             # tests must not race interrupts
+        CLGI
         movl VCPU_processor(%ebx),%eax
         shl  $IRQSTAT_shift,%eax
         testl $~0,irq_stat(%eax,1)
@@ -58,9 +45,6 @@ ENTRY(svm_asm_do_resume)
         call svm_intr_assist
         call svm_load_cr2
 
-        CLGI                
-        sti
-        GET_CURRENT(%ebx)
         movl VCPU_svm_vmcb(%ebx),%ecx
         movl UREGS_eax(%esp),%eax
         movl %eax,VMCB_rax(%ecx)
@@ -72,11 +56,15 @@ ENTRY(svm_asm_do_resume)
         popl %esi
         popl %edi
         popl %ebp
-        addl $(NR_SKIPPED_REGS*4),%esp
 
         VMRUN
 
-        HVM_SAVE_ALL_NOSEGREGS
+        pushl %ebp
+        pushl %edi
+        pushl %esi
+        pushl %edx
+        pushl %ecx
+        pushl %ebx
 
         GET_CURRENT(%ebx)
         movb $0,VCPU_svm_vmcb_in_sync(%ebx)
@@ -95,6 +83,6 @@ svm_stgi_label:
 
         ALIGN
 svm_process_softirqs:
-        sti       
+        STGI
         call do_softirq
         jmp  svm_asm_do_resume
index f7f19b889284a1459925de9e3d0efba671909ebd..54061c2e5ef785f934b83afe9c9a7057b0dc6958 100644 (file)
         andq $~7,reg;            \
         movq (reg),reg;
 
-#define HVM_MONITOR_RFLAGS 0x202 /* IF on */
-#define NR_SKIPPED_REGS    6     /* Skip SS thru error_code */
-#define HVM_SAVE_ALL_NOSEGREGS                  \
-        pushq $HVM_MONITOR_RFLAGS;              \
-        popfq;                                  \
-        subq $(NR_SKIPPED_REGS*8),%rsp;         \
-        pushq %rdi;                             \
-        pushq %rsi;                             \
-        pushq %rdx;                             \
-        pushq %rcx;                             \
-        pushq %rax;                             \
-        pushq %r8;                              \
-        pushq %r9;                              \
-        pushq %r10;                             \
-        pushq %r11;                             \
-        pushq %rbx;                             \
-        pushq %rbp;                             \
-        pushq %r12;                             \
-        pushq %r13;                             \
-        pushq %r14;                             \
-        pushq %r15;
-
 #define VMRUN  .byte 0x0F,0x01,0xD8
 #define STGI   .byte 0x0F,0x01,0xDC
 #define CLGI   .byte 0x0F,0x01,0xDD
 
 ENTRY(svm_asm_do_resume)
         GET_CURRENT(%rbx)
-        cli                             # tests must not race interrupts
+        CLGI
         movl VCPU_processor(%rbx),%eax
         shl  $IRQSTAT_shift,%rax
         leaq irq_stat(%rip),%rdx
@@ -68,9 +46,6 @@ ENTRY(svm_asm_do_resume)
         call svm_intr_assist
         call svm_load_cr2
 
-        CLGI                
-        sti
-        GET_CURRENT(%rbx)
         movq VCPU_svm_vmcb(%rbx),%rcx
         movq UREGS_rax(%rsp),%rax
         movq %rax,VMCB_rax(%rcx)
@@ -91,11 +66,24 @@ ENTRY(svm_asm_do_resume)
         popq %rdx
         popq %rsi
         popq %rdi
-        addq $(NR_SKIPPED_REGS*8),%rsp
 
         VMRUN
 
-        HVM_SAVE_ALL_NOSEGREGS
+        pushq %rdi
+        pushq %rsi
+        pushq %rdx
+        pushq %rcx
+        pushq %rax
+        pushq %r8
+        pushq %r9
+        pushq %r10
+        pushq %r11
+        pushq %rbx
+        pushq %rbp
+        pushq %r12
+        pushq %r13
+        pushq %r14
+        pushq %r15
 
         GET_CURRENT(%rbx)
         movb $0,VCPU_svm_vmcb_in_sync(%rbx)
@@ -112,6 +100,6 @@ svm_stgi_label:
 
         ALIGN
 svm_process_softirqs:
-        sti
+        STGI
         call do_softirq
         jmp  svm_asm_do_resume